<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--返回是否成年-->
<div id="content"></div>
    <input type="number" id="number" name="number" min="1" max="100">
    <button id="sex">年龄</button>
<script>
    document.getElementById('sex').onclick = function(){
        let sex = document.getElementById('number').value;
        // console.log(sex);
        let xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function (){
            if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
                console.log(xmlhttp.responseText);
                let json = JSON.parse(xmlhttp.responseText);
                console.log(json);
                // let dateSex = document.getElementById('content').innerHTML = json.date.sex;
                // console.log(dateSex);
            }
        };
        xmlhttp.open("POST","/post/ajax.php",true);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.send('sex='+sex);
    }

</script>
</body>
</html>